import 'package:get/get.dart';
import 'package:wk_robot2/app/utils/CommonUtil.dart';

import '../../../../generated/AlphaResponse.pb.dart';
import '../../../../generated/GetRobotConfiguration.pb.dart';
import '../../../../generated/NetSetWifiSwitch.pb.dart';
import '../../../models/Devices.dart';
import '../../../robot_comm/cmd_const.dart';
import '../../../robot_comm/mqtt_comm_manager.dart';

class MineWifiSettingController extends GetxController {

  var robotResponse = GetRobotConfigurationResponse().obs;

  @override
  void onInit() {
    super.onInit();

    Device device = CommonUtil.getCurrentSelectedRobot();
    if (device != null) {
      robotResponse.value.wifiname = device.wifiName;
    }

  }

  @override
  void onReady() {
    super.onReady();
    getWifiInfo();
  }

  @override
  void onClose() {
    super.onClose();
  }


  void getWifiInfo() {
    GetRobotConfigurationRequest request = GetRobotConfigurationRequest();
    MqttCommManager().sendCmd(CmdConst.IM_GET_ROBOT_CONFIG_REQUEST, request, (AlphaResponse msg) {
      robotResponse.value = GetRobotConfigurationResponse.fromBuffer(msg.bodyData);
      print('robotResponse =========> ${robotResponse.value}');
    });
  }



}
